package tedu.test.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tedu.test.entity.Product;
import tedu.test.mapper.ProductMapper;

import java.util.List;

@RestController
public class ProductController {

    @Autowired
    ProductMapper mapper;

    @RequestMapping("/product/select/category")
    public List<Product> selectByCategoryId(int cid){
        return mapper.selectByCid(cid);
    }


    @RequestMapping("/product/select")
    public List<Product> selectProduct(){
        return mapper.select();
    }

    @RequestMapping("/product/delete")
    public void deleteById(int id){
        mapper.deleteById(id);
    }

    @RequestMapping("/product/insert")
    public void insert(@RequestBody Product product){
        mapper.insert(product);
    }

}
